package com.xmx.ndmallwxapi.feign;

import com.xmx.common.utils.R;
import com.xmx.ndmallwxapi.feign.factory.OrderFallbackFatory;

import com.xmx.ndmallwxapi.vo.cart.CartAddVo;
import com.xmx.ndmallwxapi.vo.order.OrderGoodVo;
import com.xmx.ndmallwxapi.vo.order.OrderVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@FeignClient(value="order-center",fallbackFactory = OrderFallbackFatory.class)
public interface OrderFeignClient {

    /**
     * 购物车
     */
    @GetMapping("/ordercenter/cart/count/{user_id}")
     R count(@PathVariable("user_id")Integer uid);

    @GetMapping("/ordercenter/cart/queryExit")
    R queryExist( @RequestParam("goodsId") Integer goodsId, @RequestParam("productId") Integer productId,@RequestParam("userId") Integer userId);

    @PostMapping("/ordercenter/cart/save")
    R saveCart(@RequestBody CartAddVo cart);

    @PutMapping("/ordercenter/cart/update")
    R updateCart(@RequestBody Map<String, Object> params);

    @GetMapping("/ordercenter/cart/info/{id}")
    R infoCart(@PathVariable("id") Integer id);

    @PutMapping("/ordercenter/cart/clear")
    R clearCartGoods(Integer userId);

    @DeleteMapping("/ordercenter/cart/delete")
    R cartdeleteById(@RequestBody Integer[] ids);
    /**
     * 订单
     * @param userId
     * @param orderSn
     * @return
     */
    @GetMapping("/ordercenter/order/countByOrder")
    Integer countByOrderSn(@RequestParam("userId") Integer userId,@RequestParam("orderSn") String orderSn);

    @PostMapping("/ordercenter/order/save")
    R addOrder(@RequestBody OrderVo orderVo);

    @PostMapping("/ordercenter/order/submitOrder")
     R submitOrder(@RequestBody Map<String ,Object> getdata);
    /**
     * 订单商品
     * @param orderGoodVo
     * @return
     */

    @PostMapping("/ordercenter/ordergoods/save")
    R addOrderGoods(@RequestBody OrderGoodVo orderGoodVo);

}
